#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int N = 5010, MOD = 80112002;
vector<int> as[N];
int f[N];
int id[N], out[N];
int n, m;
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        as[x].push_back(y);
        id[y]++;
        out[x]++;
    }
    queue<int> q;
    for (int i = 1; i <= n; i++)
    {
        if (id[i] == 0)
        {
            f[i] = 1;
            q.push(i);
        }
    }
    while (q.size())
    {
        int a = q.front();
        q.pop();
        for (auto e : as[a])
        {
            f[e] = (f[a] + f[e]) % MOD;
            id[e]--;
            if (id[e] == 0)
            {
                q.push(e);
            }
        }
    }
    int ret = 0;
    for (int i = 1; i <= n; i++)
    {
        if (out[i] == 0)
        {
            ret = (ret + f[i]) % MOD;
        }
    }
    cout << ret;
    return 0;
}